package com.wtgroup.demo.leetcode.q012_整数转罗马数字;

/**
 * LeetCode M2
 *
 * @author dafei
 * @version 0.1
 * @date 2021/3/28 19:31
 */
public class S_LC_M2 {

    public static void main(String[] args) {
        int[] inputs = {3, 4, 9, 58, 1994, 999, 3999};
        /*
        III
        IV
        IX
        LVIII
        MCMXCIV
        CMXCIX
        MMMCMXCIX
        */
        S_LC_M2 exe = new S_LC_M2();
        for (int input : inputs) {
            System.out.println(exe.intToRoman(input));
        }
    }

    static String[] thousands = {"", "M", "MM", "MMM"};
    static String[] hundreds = {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"};
    static String[] tens = {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"};
    static String[] ones = {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"};

    public String intToRoman(int num) {
        return thousands[num / 1000] + hundreds[num % 1000 / 100] + tens[num % 100 / 10] + ones[num % 10];
    }

}
